package beast.evolution.tree;

import java.util.List;

import beast.core.Description;

@Description("Extension of Node. Allows sequence storage")
public class Node2 extends Node {
	protected List<Integer> node_seq;

	/*
	 * int array to store character state left to right: A T C G
	 */
	protected int[] charState = new int[] { -1, -1, -1, -1 };

	/* matrix to store probabilities that the character state at */
	protected double[][] pMatrix = new double[4][4];

	/* create Node2 and all the nodes below it from Node */
	public Node2(Node node) {
		m_fHeight = node.m_fHeight;
		m_iLabel = node.m_iLabel;
		m_sMetaData = node.m_sMetaData;
		m_Parent = null;
		m_sID = node.getID();
		if (node.m_left != null) {
			m_left = new Node2(node.m_left);
			m_left.m_Parent = this;
			if (node.m_right != null) {
				m_right = new Node2(node.m_right);
				m_right.m_Parent = this;
			}
		}
	}

	// getters
	public List<Integer> getSeq() {
		return node_seq;
	}
	
	public int getSeqSite (int i) {
		return node_seq.get(i);
	}

	public int[] getCharState() {
		return charState;
	}

	public double[][] getpMatrix() {
		return pMatrix;
	}

	public double getpMatrixRowSum(int RowNum) {
		double RowSum = 0.0;
		for (int j = 0; j < 4; j++) {
			RowSum = RowSum + pMatrix[RowNum][j];
		}
		return RowSum;
	}

	// setters
	public void setSeq(List<Integer> sequence) {
		node_seq = sequence;
	}

	public void setSeqSite(int i, int newSiteState) {
		node_seq.set(i, newSiteState);
	}
	
	public void setCharState(int[] newCharState) {
		charState = newCharState;
	}
	
	public void setCharStateNegative() {
		charState = new int [] {-1,-1,-1,-1};
	}

	public void setpMatrix(int i, int j, double pSingleEntry) {
		pMatrix[i][j] = pSingleEntry;
	}
}